package com.example.chapter13;

import java.io.BufferedWriter;
import java.io.FileWriter;
import java.io.IOException;

/*
 * 13.2.3.文本文件的数据处理-写入文本文件-使用java.io
 * */
public class TextFileWriterIo {

    public static void main(String[] args) {
        BufferedWriter writer = null;
        try {
            writer = new BufferedWriter(new FileWriter("path/to/your/textfile.txt"));
            writer.write("First line");
            writer.newLine();
            writer.write("Second line");
            writer.newLine();
            writer.write("Third line");
        } catch (IOException e) {
            e.printStackTrace();
        } finally {
            if (writer != null) {
                try {
                    writer.close();
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
        }
    }
}
